﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Comment
{
    /// <summary>
    /// 获得所有的留言
    /// </summary>
    /// <returns></returns>
    public DataTable GetAllComments()
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetAllComments();
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获得某种乐器的留言
    /// </summary>
    /// <param name="nBookID"></param>
    /// <returns></returns>
    public DataTable GetCommentByInstrument(int nInstruID)
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetCommentByInstru(nInstruID);
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获得某一留言
    /// </summary>
    /// <param name="nCommentID"></param>
    /// <returns></returns>
    public DataTable GetSingleComment(int nCommentID)
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetSingleComment(nCommentID);
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 添加留言
    /// </summary>
    /// <param name="sDesn"></param>
    /// <param name="sBody"></param>
    /// <param name="nBookID"></param>
    /// <param name="nUserID"></param>
    /// <returns></returns>
    public int AddComment(string content, int nInstruID, int nUserID)
    {
        DataModelDataContext data = new DataModelDataContext();
        int id = data.Pr_AddComment(nInstruID, content, nUserID);
        return id;
    }

    public void DeleteComment(int nCommentID)
    {
        DataModelDataContext data = new DataModelDataContext();
        data.Pr_DeleteComment(nCommentID);
    }
}